// pages/tooth4/tooth4.js
const app=getApp()
Page({
  data: {
    typeList:[],
    images:["https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/ze-arrow-left%20lmgi6zF@3x.png","https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/tooth4/fatherback.png","https://gitee.com/ToBugCoding/my-photo-bed/raw/master/imgurl/%E5%85%AC%E5%8F%B8%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%87%8D%E5%86%99/tooth4/bg.png"],
    loadedImages:0,
    ifready:true,
  },
  back:function(){
    wx.switchTab({
      url: '/pages/head/head',
    })
  },
  examine:function(e){
    var p=e.currentTarget.dataset.id
    app.globalData.nowQuest=this.data.typeList[p]
    // console.log(app.globalData.userList[0])
    // console.log(app.globalData.nowQuest)
    wx.navigateTo({
      url: '/pages/toothExam/toothExam',
    })
  },
  onShow() {
    var list=app.globalData.userList
    this.setData({
      typeList:list
    })
  },
  onLoad(){
    var that=this
    if(that.data.ifready!='none'){
      let images = this.data.images;
      images.forEach((imgSrc, index) => {
        wx.getImageInfo({
          src: imgSrc,
          success: () => {
            // 图片加载成功
            this.setData({
              loadedImages: this.data.loadedImages + 1
            });
            if (this.data.loadedImages === images.length) {
              if(this.data.ifready==true)
              {
                setTimeout(() => {
                  that.setData({
                    ifready:'none'
                  })
                }, 500);
              }
            }
          },
          fail: () => {
            // 图片加载失败
            console.log(`图片${index + 1}加载失败`);
          }
        });
      });
    }
  }
})